#ifndef CELLPARSE_H
#define CELLPARSE_H

#include <QXmlDefaultHandler>
#include <QMessageBox>
#include <QMap>


class CellParser : public QXmlDefaultHandler
{
public:
	CellParser(QMap<int, QString>* map):listOfProd(map)
	{};

	bool startDocument()
	{
		inAdBook = false;
		return true;
	}
	bool endElement( const QString&, const QString&, const QString &name )
	{
		if( name == "root" )
			inAdBook = false;

		return true;
	}

	bool startElement( const QString&, const QString&, const QString &name, const QXmlAttributes &attrs )
	{
		if( inAdBook && name == "cell" )
		{
			QString id, name_;

				if( attrs.localName( 0 ) == "id" && attrs.localName( 1 ) == "name" )
				{
					listOfProd->insert(attrs.value(0).toInt(),attrs.value(1));
					//QMessageBox::information( 0, "cell", attrs.value(0) + "\t" + attrs.value(1)  );
				}
		}
		else if( name == "root" )
			inAdBook = true;

		return true;
	}

private:
	bool inAdBook;
    QMap<int, QString>* listOfProd;
};

#endif